/*
 * @(#)UserServiceImpl.java	2013-3-31 下午8:11:16
 * intranet
 * Copyright 2013 Thuisoft, Inc. All rights reserved.
 * THUNISOFT PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.thunisoft.intranet.user.service.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.thunisoft.intranet.domain.TUser;
import com.thunisoft.intranet.user.dao.IUserDAO;
import com.thunisoft.intranet.user.service.IUserService;

/**
 * UserServiceImpl
 * 
 * @author ice
 * @version 1.0
 * 
 */
public class UserServiceImpl implements IUserService {

    /**
     * 日志对象
     */
    Logger logger = Logger.getLogger(this.getClass());

    /**
     * 会话工厂
     */
    @Autowired
    private SessionFactory sessionFactory;

    /**
     * 用户DAO对象
     */
    @Autowired
    public IUserDAO userDAO;

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.thunisoft.intranet.login.service.IUserService#saveOrUpdate(com.thunisoft
     * .intranet.domain.TUser)
     */
    @Override
    public void saveOrUpdate(TUser user) {
        Session session = sessionFactory.openSession();
        Transaction transaction = session.getTransaction();
        try {
            transaction.begin();
            userDAO.saveOrUpdate(user);
            transaction.commit();
        } catch (Exception e) {
            transaction.rollback();
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.thunisoft.intranet.user.service.IUserService#getAllUserList()
     */
    @Override
    public List<TUser> getAllUserList() {
        return userDAO.getAllUserList();
    }
}
